-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: SparseSeries.shift may raise NameError or TypeError #12908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -159,6 +22,58 @@ def setUp(self): | |||
self.arr = SparseArray(self.arr_data) | |||
self.zarr = SparseArray([0, 0, 1, 2, 3, 0, 4, 5, 0, 6], fill_value=0) | |||
|
|||
def test_constructor_dtype(self): | |||
arr = SparseArray([np.nan, 1, 2, np.nan]) | |||
self.assertEqual(arr.dtype, np.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would test the fill_value on all of the these (e.g. nan as the default, 0 on next example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more tests in test_shift_nan
. Is this what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no I meant that you are asserting the fill_value
in some of the tests here (as well as the dtype), but might want to assert fill_value for all (an example will be when we have nan fill values that we DO coerce on creation), e.g. say we have sparse datetimes (we don't really support this ATM)
pd.SparseArray([pd.NaT, pd.Timestamp('20130101'), pd.Timestamp('20130102'), pd.NaT], fill_value=np.nan)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no I get it. I just want a line that says self.assertTrue(np.isnan(arr.fill_value))
on the tests that don't have this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Added missing checks.
thanks! sparse is really looking nice! |
git diff upstream/master | flake8 --diff
Fixed following bugs on current master. Also, moved
TestSparseArrayIndex
totest_libsparse
1. shift
2. dtype